< previous page page_581 next page >

Page 581
In a real application environment, you wouldn't want to show the procedure stack each time an error is reported. The best place for a stack dump is at exit time due to a fatal error. You should probably use the TraceFile option to write the stack to disk rather than displaying it to the user.
Other Error Handler Options
Now that you have the basics of error handling under your belt, you can continue to add features to the generic error handler. As you add these features, your programs take on a more professional look and feel. Also, using options such as error report logs and procedure stack logs makes it easier to debug and maintain your applications.
Additional features that you can add to your error handler include:
· Add the name of the user or workstation address to the reports.
· If you have created an error trap for common errors, such as Error 53File not found, add that recovery code to your generic handler. Now you can count on consistent handling of common errors without adding code to every project.
Summary
Today's lesson covered all the basics of creating your own error-handling routines for Visual Basic applications. You learned that an error handler has three basic parts:
· The On Error Goto statement
· The body of the error handler code
· The error handler exit
You learned that an error handler has four possible exits:
·Resume: Re-executes the code that caused the error.
·Resume Next: Continues processing at the line immediately following the code line that caused the error.
·Resume label: Continues processing at the location identified by the label.
·EXIT or END: EXIT ends processing for the current routine, and END exits the program completely.
You learned how to use the Err.Raise method to flag errors without resorting to modal dialog boxes.

 
< previous page page_581 next page >

If you like this book, buy it!